load("@rules_proto//proto:defs.bzl", "proto_library")
load("@io_bazel_rules_go//proto:def.bzl", "go_proto_library")
load("@io_bazel_rules_go//go:def.bzl", "go_library", "go_test")

go_library(
    name = "optional",
    srcs = [
        "duration.go",
        "uint.go",
    ],
    embed = [":optional_go_proto"],
    importpath = "github.com/cockroachdb/cockroach/pkg/util/optional",
    visibility = ["//visibility:public"],
)

go_test(
    name = "optional_test",
    size = "small",
    srcs = [
        "duration_test.go",
        "uint_test.go",
    ],
    deps = [
        ":optional",
        "@com_github_stretchr_testify//require",
    ],
)

proto_library(
    name = "optional_proto",
    srcs = ["optional.proto"],
    strip_import_prefix = "/pkg",
    visibility = ["//visibility:public"],
    deps = [
        "@com_github_gogo_protobuf//gogoproto:gogo_proto",
        "@com_google_protobuf//:duration_proto",
    ],
)

go_proto_library(
    name = "optional_go_proto",
    compilers = ["//pkg/cmd/protoc-gen-gogoroach:protoc-gen-gogoroach_compiler"],
    importpath = "github.com/cockroachdb/cockroach/pkg/util/optional",
    proto = ":optional_proto",
    visibility = ["//visibility:public"],
    deps = ["@com_github_gogo_protobuf//gogoproto"],
)
